package com.impress.commons.exception;

/**
 * @author Wangyi
 * @since 2016年6月23日
 */
public class ErrorResponsePortableException extends RuntimeException {

	private static final long serialVersionUID = 6879795219755217330L;

	private final ErrorResponse errorResponse;

	/**
	 * @param errorResponse
	 */
	public ErrorResponsePortableException(ErrorResponse errorResponse) {
		super();
		this.errorResponse = errorResponse;
	}

	/**
	 * @return the errorResponse
	 */
	public ErrorResponse getErrorResponse() {
		return errorResponse;
	}

	@Override
	public String getMessage() {
		if (errorResponse.getDetail() != null) {
			return errorResponse.getMessage() + " -> " + errorResponse.getDetail();
		}
		return errorResponse.getMessage();
	}

}
